package com.softstao.guoyu.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.softstao.guoyu.R;
import com.softstao.guoyu.model.sale.OrderGoods;
import com.softstao.guoyu.ui.baseAdapter.RecycleViewBaseAdapter;
import com.softstao.guoyu.ui.baseAdapter.RecycleViewHolder;
import com.softstao.softstaolibrary.library.utils.LZUtils;

import java.util.List;

/**
 * Created by vaikus on 2017/6/16.
 */

public class OrderGoodsAdapter extends RecycleViewBaseAdapter<OrderGoods> {
    private int status;

    public OrderGoodsAdapter(List<OrderGoods> datas) {
        super(datas, R.layout.layout_order_goods_item);
    }

    @Override
    public void convert(RecycleViewHolder holder, OrderGoods orderGoods) {
        RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        holder.itemView.setLayoutParams(layoutParams);
        if (orderGoods.getImg()!=null && !orderGoods.getImg().equals("")){
            Glide.with(mContext).load(orderGoods.getImg()).into((ImageView) holder.getView(R.id.img));
        }else {
            ((ImageView) holder.getView(R.id.img)).setImageResource(R.mipmap.default_im);
        }
        holder.setText(R.id.name, orderGoods.getName())
                .setText(R.id.price, mContext.getResources().getString(R.string.rmb) + LZUtils.priceFormat(orderGoods.getPrice()))
                .setText(R.id.num, "x" + orderGoods.getNum() + "台");
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
}
